package com.cndongtai.controller.monitor;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cndongtai.controller.BaseController;
import com.cndongtai.service.light.LightService;
import com.cndongtai.util.ValidateUtil;
import com.cndongtai.vo.LightBean;

@Controller
public class MonitorController extends BaseController{
	
	@Resource(name="lightService")
	private LightService lightService;
	
	@RequestMapping("/monitor")
	public String showMonitorPage() {
		String json = lightService.getLightJsonTree();
		request.setAttribute("jsontree", json);
		
		return "/monitor/monitor";
	}
	
	@RequestMapping("/showLightList")
	public String showLightList() {
		String nodes = this.getValue("nodes");
		
		if(ValidateUtil.notEmpty(nodes)) {
			List<LightBean> lightList = lightService.queryLightListByIds(nodes);
			request.setAttribute("lightList", lightList);
		}

		return "/monitor/lightList";
	}

}
